#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <set>

#define flr(x, l, r) for (int x = l; x <= r; ++x)
#define frl(x, r, l) for (int x = r; x >= l; --x)
#define fmp(x, t) for (int x = h[t]; ~x; x = ne[x])
#define LL long long
#define mt memset
#define my memcpy
#define szf sizeof
#define INF 0x3f3f3f3f
#define in(x) scanf("%d", &x)
#define out(x) printf("%d", x)
#define inll(x) scanf("%lld", &x)
#define outll(x) printf("%lld", x)
#define pn printf("\n")
#define con continue
#define bk break
#define vc vector
#define pb push_back
#define sz size
#define PII pair<int, int>
#define x first
#define y second
#define P_q priority_queue
#define ft front
#define pf push_front
#define popf pop_front
#define it insert
#define ct count

using namespace std;

const int N = 160;
const double DINF = 1e20;

int n;
PII q[N];
char g[N][N];
double maxd[N], dist[N][N];

double get_dist(PII a, PII b) {
    double dx = a.x - b.x, dy = a.y - b.y;
    return sqrt(dx * dx +  dy * dy);
}

int main() {
	in(n);
	
	flr (i, 0, n - 1) in(q[i].x), in(q[i].y);
	
	flr (i, 0, n - 1) cin >> g[i];
	
	flr (i, 0, n - 1)
	    flr (j, 0, n - 1)
	        if (i != j) {
	            if (g[i][j] == '1') dist[i][j] = get_dist(q[i], q[j]);
	            else dist[i][j] = DINF;
	        }
    
    flr (k, 0, n - 1)
        flr (i, 0, n - 1)
            flr (j, 0, n - 1)
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    
    flr (i, 0, n - 1)
        flr (j, 0, n - 1)
            if (dist[i][j] < DINF)
                maxd[i] = max(maxd[i], dist[i][j]);
    
    double res1 = 0;
    flr (i, 0, n - 1) res1 = max(res1, maxd[i]);
    
    double res2 = DINF;
    flr (i, 0, n - 1)
        flr (j, 0, n - 1)
            if (dist[i][j] >= DINF)
                res2 = min(res2, get_dist(q[i], q[j]) + maxd[i] + maxd[j]);
    
    printf("%.6lf\n", max(res1, res2));
    
    return 0;
}